package me.yricky.alia.arcane

import com.google.gson.Gson
import java.io.InputStream

/**
 * @author Yricky
 * @date 2022/1/31
 */
data class ArcaneMetadata(
    val arcaneId:String = "",
    val versionName:String = "",
    val versionCode:Int = 0,
    val preloads:List<String> = emptyList(),
    val extras:Map<String,String> = emptyMap(),
)

fun ArcaneMetadata.isValid():Boolean = arcaneId.isNotEmpty()

fun loadMetaData(input:InputStream): ArcaneMetadata {
    return try{
        Gson().fromJson(input.reader(), ArcaneMetadata::class.java)
    }catch (e:Throwable){
        ArcaneMetadata()
    }
}